#!/bin/bash -e

export SIM_TOOL=$1

if [ "$2" == "" ]; then
    export UVM_VERSION=uvm-1.1d
else
    export UVM_VERSION=$2
fi

if [ "$SIM_TOOL" == "VCS" -o "$SIM_TOOL" == "NCSIM" -o "$SIM_TOOL" == "QUESTA" ]; then
    export UVM_HOME=~/uvm/$UVM_VERSION
    export WORK_HOME=`pwd`
    export PATH=$PATH:${WORK_HOME}/bin:${UVM_HOME}/bin
    echo "setup successfully!"
else
    echo "USAGE: setup.sh SIM_TOOL [UVM_VERSION] # SIM_TOOL must be VCS/NCSIM/QUESTA, UVM_VERSION is optinal, default uvm-1.1d"
fi

if [ "$SIM_TOOL" == "QUESTA" ]; then
    export UVM_DPI_DIR=$WORK_HOME/uvm_dpi
    mkdir -p $UVM_DPI_DIR
    g++ $UVM_HOME/src/dpi/uvm_dpi.cc -D QUESTA -I$UVM_HOME/src/dpi -I$QUESTA_HOME/include -shared -Bsymbolic -o $UVM_DPI_DIR/uvm_dpi.so
fi
